package com.niguang.work.show.sms;

import com.niguang.work.show.common.pojo.Result;
import com.niguang.work.show.sms.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 短信发送控制类
 */
@RestController
@RequestMapping("/api/sms/")
@Slf4j
public class SmsController {


    @Resource
    private SmsService smsService;


    /**
     * 发送短信验证码
     *
     * @param userPhone
     * @return
     */
    @GetMapping("open/sendSms/v1")
    public Result sendSms(@NotNull @RequestParam String userPhone) {
        return smsService.sendSms(userPhone);
    }


    /**
     * 获取短信验证码
     * @param userPhone
     * @return
     */
    @GetMapping("open/getSmsCode/v1")
    public String getSmsCode(String userPhone) {
        return smsService.getSmsCode(userPhone);
    }
}
